<?php

class actLogin extends action
{
	function execute($m)
	{
		// Retrieve user model
		$uM = $m->getModel('user');
		
		// Is it correct?
		if ($uM->check($this->getInput('u'), $this->getInput('p')))
		{
			$this->addOutput('1');
			
			// Set right user.
			$uM->setUser($this->GetInput('u'), 'username');
			
			if ($uM->getStatus() > 0)
				$this->setOutput('-1');
			else
			{
				// Set the status to active
				$uM->setActive();
				
				$this->addOutput($uM->getUsername());
				$this->addOutput($uM->getStatus());
				$this->addOutput($uM->getStatusDetailed());
				$this->addOutput($uM->getNickname());
				
				// Save the action
				$this->act($m, $uM->getID() . ',status,' . $uM->getStatus(), 'contacts');
				
				$this->setSession('loop_seed', -1);
				$this->setSession('user', $uM->getID());
				
			} // end else
		} // end if
		else
		{
			$this->addOutput('0');
			
		} // end else
		
		$this->finish();
		
	} // end function
	
} // end class

$_ = 'actLogin';

?>